<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>随机链接</title>
</head>

<body>
    <p id="demo"></p>
    <script>
        var r = Math.random();
        var x = document.getElementById("demo")
        if (r > 0.5) {
            x.innerHTML = "<a href='http://www.runoob.com'>访问菜鸟教程</a>";
        }
        else {
            x.innerHTML = "<a href='http://wwf.org'>Visit WWF</a>";
        }
    </script>
</body>

</html>